#include <iostream>
using namespace std;

#define  shift 3
#define  mask 0x7
unsigned char  bitmap[4];

void setbit(unsigned char *bitmap, int i)
{
	 /*int nbytepos=i>>shift;
	 int nbitpos=i&7;
	 unsigned short val=1<<nbitpos;
	 bitmap[nbytepos]|=val;*/
	bitmap[i >> shift] |= (1 << (i & mask)); 
}
int getbit(unsigned char *bitmap1, int i)
{    
	return bitmap1[i >> shift] & (1 << (i & mask));    
}   
int  test(int i)
{ 
	return bitmap[i>>shift]&(1<<(i & mask)); 
} 

int main()
{
	
     int a[]={3,2,1,4,9,31,30};
	int len=sizeof(a)/sizeof(a[0]);
	for (int i=0;i<len;i++)
	{
		setbit(bitmap,a[i]);
	}
	for (int i=0;i<32;i++)
	{
		if (test(i))
		{
			cout<<i<<" ";
		}
	return 0;
}